package com.itheima.order.controller;

import com.itheima.goods.pojo.Goods;
import com.itheima.order.service.GoodsService;
import entity.Result;
import entity.StatusCode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/goods")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @GetMapping("/{goodId}")
    public Result<Goods> findGoodsById(@PathVariable("goodId") Integer goodId){
        Goods goods = this.goodsService.findGoodsById(goodId);
        return new Result<Goods>(true, StatusCode.OK,"查询成功",goods);
    }
}
